<template>
  <div>
    <el-dialog width="80%" :visible.sync="dialogVisible" @close="onClose" :title="title">
      <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="用户ID" prop="userid">
            <el-input :disabled="true" v-model="queryParams.userid" placeholder="请输入userid" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="转赠类型" prop="type">
            <el-select style="width: 240px" v-model="queryParams.type" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="roleList" >
          <el-table-column label="转出方用户ID" prop="fromUserId" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.fromUserId || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="转出方用户ID编号" prop="fromIdNumber" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.fromIdNumber || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="转出方用户昵称" prop="fromNickname" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.fromNickname || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="转入方用户ID" prop="toUserId" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.toUserId || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="转入方用户ID编号" prop="toIdNumber" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.toIdNumber || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="转入方用户昵称" align="center" min-width="120px" prop="toNickname">
            <template #default="{row}">
              <div>
                {{row.toNickname || '--'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="quantity" align="center" min-width="120px">
            <template #default="{row}">
              <div>
                {{row.quantity || '--'}}
              </div>
            </template>
          </el-table-column>

          <el-table-column label="发起转赠的时间" align="center" prop="transferTime"  width="160">
            <template #default="{row}">
              <span>{{ parseTime(row.transferTime) || '--' }}</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNo"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </el-dialog>
  </div>
</template>
<script>

import {giftingInfoPage} from "@/api/user/user"

export default {
  data() {
    return {
      title:'流水明细',
      dialogVisible: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      // 弹出层标题
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        type:'0',//排序 0 转出方，转入方
        userid:undefined,//ID
      },
      options: [{
        value: '0',
        label: '转出方'
      }, {
        value: '1',
        label: '转入方'
      }],
      imageUrl:"http://192.168.1.99:8802",
      userid:undefined,
    }
  },
  methods: {
    // 弹窗
    async onOpen(userid) {
      this.queryParams.userid = userid
      this.title="转赠记录"
      this.dialogVisible = true
      this.getList()
    },
    async getList(){
      let res = await giftingInfoPage(this.queryParams)
      this.roleList= res.data.records
      this.total = res.data.total
      this.loading = false
    },
    onClose() {

    },
    // 表单重置
    reset() {
      this.resetForm("form")
      this.queryParams.type='0'
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm("queryForm")
      this.queryParams.type='0'
      this.handleQuery()
    },
  }
}

</script>
<style>
.el-upload__tip {
  line-height: 1.2;
}

</style>
